// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Ingest;

[JsonConverter(typeof(ProcessorConverter))]
public sealed partial class Processor
{
	internal Processor(string variantName, object variant)
	{
		if (variantName is null)
			throw new ArgumentNullException(nameof(variantName));
		if (variant is null)
			throw new ArgumentNullException(nameof(variant));
		if (string.IsNullOrWhiteSpace(variantName))
			throw new ArgumentException("Variant name must not be empty or whitespace.");
		VariantName = variantName;
		Variant = variant;
	}

	internal object Variant { get; }
	internal string VariantName { get; }

	public static Processor Append(Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor appendProcessor) => new Processor("append", appendProcessor);
	public static Processor Attachment(Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor attachmentProcessor) => new Processor("attachment", attachmentProcessor);
	public static Processor Bytes(Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor bytesProcessor) => new Processor("bytes", bytesProcessor);
	public static Processor Circle(Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor circleProcessor) => new Processor("circle", circleProcessor);
	public static Processor CommunityId(Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor communityIDProcessor) => new Processor("community_id", communityIDProcessor);
	public static Processor Convert(Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor convertProcessor) => new Processor("convert", convertProcessor);
	public static Processor Csv(Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor csvProcessor) => new Processor("csv", csvProcessor);
	public static Processor Date(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor dateProcessor) => new Processor("date", dateProcessor);
	public static Processor DateIndexName(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor dateIndexNameProcessor) => new Processor("date_index_name", dateIndexNameProcessor);
	public static Processor Dissect(Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor dissectProcessor) => new Processor("dissect", dissectProcessor);
	public static Processor DotExpander(Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor dotExpanderProcessor) => new Processor("dot_expander", dotExpanderProcessor);
	public static Processor Drop(Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor dropProcessor) => new Processor("drop", dropProcessor);
	public static Processor Enrich(Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor enrichProcessor) => new Processor("enrich", enrichProcessor);
	public static Processor Fail(Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor failProcessor) => new Processor("fail", failProcessor);
	public static Processor Fingerprint(Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor fingerprintProcessor) => new Processor("fingerprint", fingerprintProcessor);
	public static Processor Foreach(Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor foreachProcessor) => new Processor("foreach", foreachProcessor);
	public static Processor GeoGrid(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor geoGridProcessor) => new Processor("geo_grid", geoGridProcessor);
	public static Processor Geoip(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor geoIpProcessor) => new Processor("geoip", geoIpProcessor);
	public static Processor Grok(Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor grokProcessor) => new Processor("grok", grokProcessor);
	public static Processor Gsub(Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor gsubProcessor) => new Processor("gsub", gsubProcessor);
	public static Processor HtmlStrip(Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor htmlStripProcessor) => new Processor("html_strip", htmlStripProcessor);
	public static Processor Inference(Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor inferenceProcessor) => new Processor("inference", inferenceProcessor);
	public static Processor Join(Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor joinProcessor) => new Processor("join", joinProcessor);
	public static Processor Json(Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor jsonProcessor) => new Processor("json", jsonProcessor);
	public static Processor Kv(Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor keyValueProcessor) => new Processor("kv", keyValueProcessor);
	public static Processor Lowercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor lowercaseProcessor) => new Processor("lowercase", lowercaseProcessor);
	public static Processor NetworkDirection(Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor networkDirectionProcessor) => new Processor("network_direction", networkDirectionProcessor);
	public static Processor Pipeline(Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor pipelineProcessor) => new Processor("pipeline", pipelineProcessor);
	public static Processor Redact(Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor redactProcessor) => new Processor("redact", redactProcessor);
	public static Processor RegisteredDomain(Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor registeredDomainProcessor) => new Processor("registered_domain", registeredDomainProcessor);
	public static Processor Remove(Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor removeProcessor) => new Processor("remove", removeProcessor);
	public static Processor Rename(Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor renameProcessor) => new Processor("rename", renameProcessor);
	public static Processor Reroute(Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor rerouteProcessor) => new Processor("reroute", rerouteProcessor);
	public static Processor Script(Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor scriptProcessor) => new Processor("script", scriptProcessor);
	public static Processor Set(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor setProcessor) => new Processor("set", setProcessor);
	public static Processor SetSecurityUser(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor setSecurityUserProcessor) => new Processor("set_security_user", setSecurityUserProcessor);
	public static Processor Sort(Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor sortProcessor) => new Processor("sort", sortProcessor);
	public static Processor Split(Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor splitProcessor) => new Processor("split", splitProcessor);
	public static Processor Terminate(Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor terminateProcessor) => new Processor("terminate", terminateProcessor);
	public static Processor Trim(Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor trimProcessor) => new Processor("trim", trimProcessor);
	public static Processor Uppercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor uppercaseProcessor) => new Processor("uppercase", uppercaseProcessor);
	public static Processor UriParts(Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor uriPartsProcessor) => new Processor("uri_parts", uriPartsProcessor);
	public static Processor UrlDecode(Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor urlDecodeProcessor) => new Processor("urldecode", urlDecodeProcessor);
	public static Processor UserAgent(Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor userAgentProcessor) => new Processor("user_agent", userAgentProcessor);

	public bool TryGet<T>([NotNullWhen(true)] out T? result) where T : class
	{
		result = default;
		if (Variant is T variant)
		{
			result = variant;
			return true;
		}

		return false;
	}
}

internal sealed partial class ProcessorConverter : JsonConverter<Processor>
{
	public override Processor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
	{
		if (reader.TokenType != JsonTokenType.StartObject)
		{
			throw new JsonException("Expected start token.");
		}

		object? variantValue = default;
		string? variantNameValue = default;
		while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
		{
			if (reader.TokenType != JsonTokenType.PropertyName)
			{
				throw new JsonException("Expected a property name token.");
			}

			if (reader.TokenType != JsonTokenType.PropertyName)
			{
				throw new JsonException("Expected a property name token representing the name of an Elasticsearch field.");
			}

			var propertyName = reader.GetString();
			reader.Read();
			if (propertyName == "append")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "attachment")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "bytes")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "circle")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "community_id")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "convert")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "csv")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "date")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "date_index_name")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "dissect")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "dot_expander")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "drop")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "enrich")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "fail")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "fingerprint")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "foreach")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geo_grid")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "geoip")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "grok")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "gsub")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "html_strip")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "inference")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "join")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "json")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "kv")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "lowercase")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "network_direction")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "pipeline")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "redact")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "registered_domain")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "remove")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "rename")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "reroute")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "script")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "set")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "set_security_user")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "sort")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "split")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "terminate")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "trim")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "uppercase")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "uri_parts")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "urldecode")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			if (propertyName == "user_agent")
			{
				variantValue = JsonSerializer.Deserialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor?>(ref reader, options);
				variantNameValue = propertyName;
				continue;
			}

			throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Processor' from the response.");
		}

		var result = new Processor(variantNameValue, variantValue);
		return result;
	}

	public override void Write(Utf8JsonWriter writer, Processor value, JsonSerializerOptions options)
	{
		writer.WriteStartObject();
		if (value.VariantName is not null && value.Variant is not null)
		{
			writer.WritePropertyName(value.VariantName);
			switch (value.VariantName)
			{
				case "append":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor)value.Variant, options);
					break;
				case "attachment":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor)value.Variant, options);
					break;
				case "bytes":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor)value.Variant, options);
					break;
				case "circle":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor)value.Variant, options);
					break;
				case "community_id":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor)value.Variant, options);
					break;
				case "convert":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor)value.Variant, options);
					break;
				case "csv":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor)value.Variant, options);
					break;
				case "date":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor)value.Variant, options);
					break;
				case "date_index_name":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor)value.Variant, options);
					break;
				case "dissect":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor)value.Variant, options);
					break;
				case "dot_expander":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor)value.Variant, options);
					break;
				case "drop":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor)value.Variant, options);
					break;
				case "enrich":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor)value.Variant, options);
					break;
				case "fail":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor)value.Variant, options);
					break;
				case "fingerprint":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor)value.Variant, options);
					break;
				case "foreach":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor)value.Variant, options);
					break;
				case "geo_grid":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor)value.Variant, options);
					break;
				case "geoip":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor)value.Variant, options);
					break;
				case "grok":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor)value.Variant, options);
					break;
				case "gsub":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor)value.Variant, options);
					break;
				case "html_strip":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor)value.Variant, options);
					break;
				case "inference":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor)value.Variant, options);
					break;
				case "join":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor)value.Variant, options);
					break;
				case "json":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor)value.Variant, options);
					break;
				case "kv":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor)value.Variant, options);
					break;
				case "lowercase":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor)value.Variant, options);
					break;
				case "network_direction":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor)value.Variant, options);
					break;
				case "pipeline":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor)value.Variant, options);
					break;
				case "redact":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor)value.Variant, options);
					break;
				case "registered_domain":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor)value.Variant, options);
					break;
				case "remove":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor)value.Variant, options);
					break;
				case "rename":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor)value.Variant, options);
					break;
				case "reroute":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor)value.Variant, options);
					break;
				case "script":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor)value.Variant, options);
					break;
				case "set":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor)value.Variant, options);
					break;
				case "set_security_user":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor)value.Variant, options);
					break;
				case "sort":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor)value.Variant, options);
					break;
				case "split":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor)value.Variant, options);
					break;
				case "terminate":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor)value.Variant, options);
					break;
				case "trim":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor)value.Variant, options);
					break;
				case "uppercase":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor)value.Variant, options);
					break;
				case "uri_parts":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor)value.Variant, options);
					break;
				case "urldecode":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor)value.Variant, options);
					break;
				case "user_agent":
					JsonSerializer.Serialize<Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor>(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor)value.Variant, options);
					break;
			}
		}

		writer.WriteEndObject();
	}
}

public sealed partial class ProcessorDescriptor<TDocument> : SerializableDescriptor<ProcessorDescriptor<TDocument>>
{
	internal ProcessorDescriptor(Action<ProcessorDescriptor<TDocument>> configure) => configure.Invoke(this);

	public ProcessorDescriptor() : base()
	{
	}

	private bool ContainsVariant { get; set; }
	private string ContainedVariantName { get; set; }
	private object Variant { get; set; }
	private Descriptor Descriptor { get; set; }

	private ProcessorDescriptor<TDocument> Set<T>(Action<T> descriptorAction, string variantName) where T : Descriptor
	{
		ContainedVariantName = variantName;
		ContainsVariant = true;
		var descriptor = (T)Activator.CreateInstance(typeof(T), true);
		descriptorAction?.Invoke(descriptor);
		Descriptor = descriptor;
		return Self;
	}

	private ProcessorDescriptor<TDocument> Set(object variant, string variantName)
	{
		Variant = variant;
		ContainedVariantName = variantName;
		ContainsVariant = true;
		return Self;
	}

	public ProcessorDescriptor<TDocument> Append(Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor appendProcessor) => Set(appendProcessor, "append");
	public ProcessorDescriptor<TDocument> Append(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessorDescriptor<TDocument>> configure) => Set(configure, "append");
	public ProcessorDescriptor<TDocument> Attachment(Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor attachmentProcessor) => Set(attachmentProcessor, "attachment");
	public ProcessorDescriptor<TDocument> Attachment(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessorDescriptor<TDocument>> configure) => Set(configure, "attachment");
	public ProcessorDescriptor<TDocument> Bytes(Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor bytesProcessor) => Set(bytesProcessor, "bytes");
	public ProcessorDescriptor<TDocument> Bytes(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessorDescriptor<TDocument>> configure) => Set(configure, "bytes");
	public ProcessorDescriptor<TDocument> Circle(Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor circleProcessor) => Set(circleProcessor, "circle");
	public ProcessorDescriptor<TDocument> Circle(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessorDescriptor<TDocument>> configure) => Set(configure, "circle");
	public ProcessorDescriptor<TDocument> CommunityId(Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor communityIDProcessor) => Set(communityIDProcessor, "community_id");
	public ProcessorDescriptor<TDocument> CommunityId(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessorDescriptor<TDocument>> configure) => Set(configure, "community_id");
	public ProcessorDescriptor<TDocument> Convert(Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor convertProcessor) => Set(convertProcessor, "convert");
	public ProcessorDescriptor<TDocument> Convert(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessorDescriptor<TDocument>> configure) => Set(configure, "convert");
	public ProcessorDescriptor<TDocument> Csv(Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor csvProcessor) => Set(csvProcessor, "csv");
	public ProcessorDescriptor<TDocument> Csv(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessorDescriptor<TDocument>> configure) => Set(configure, "csv");
	public ProcessorDescriptor<TDocument> Date(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor dateProcessor) => Set(dateProcessor, "date");
	public ProcessorDescriptor<TDocument> Date(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessorDescriptor<TDocument>> configure) => Set(configure, "date");
	public ProcessorDescriptor<TDocument> DateIndexName(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor dateIndexNameProcessor) => Set(dateIndexNameProcessor, "date_index_name");
	public ProcessorDescriptor<TDocument> DateIndexName(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessorDescriptor<TDocument>> configure) => Set(configure, "date_index_name");
	public ProcessorDescriptor<TDocument> Dissect(Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor dissectProcessor) => Set(dissectProcessor, "dissect");
	public ProcessorDescriptor<TDocument> Dissect(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessorDescriptor<TDocument>> configure) => Set(configure, "dissect");
	public ProcessorDescriptor<TDocument> DotExpander(Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor dotExpanderProcessor) => Set(dotExpanderProcessor, "dot_expander");
	public ProcessorDescriptor<TDocument> DotExpander(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessorDescriptor<TDocument>> configure) => Set(configure, "dot_expander");
	public ProcessorDescriptor<TDocument> Drop(Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor dropProcessor) => Set(dropProcessor, "drop");
	public ProcessorDescriptor<TDocument> Drop(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessorDescriptor<TDocument>> configure) => Set(configure, "drop");
	public ProcessorDescriptor<TDocument> Enrich(Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor enrichProcessor) => Set(enrichProcessor, "enrich");
	public ProcessorDescriptor<TDocument> Enrich(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessorDescriptor<TDocument>> configure) => Set(configure, "enrich");
	public ProcessorDescriptor<TDocument> Fail(Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor failProcessor) => Set(failProcessor, "fail");
	public ProcessorDescriptor<TDocument> Fail(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessorDescriptor<TDocument>> configure) => Set(configure, "fail");
	public ProcessorDescriptor<TDocument> Fingerprint(Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor fingerprintProcessor) => Set(fingerprintProcessor, "fingerprint");
	public ProcessorDescriptor<TDocument> Fingerprint(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessorDescriptor<TDocument>> configure) => Set(configure, "fingerprint");
	public ProcessorDescriptor<TDocument> Foreach(Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor foreachProcessor) => Set(foreachProcessor, "foreach");
	public ProcessorDescriptor<TDocument> Foreach(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessorDescriptor<TDocument>> configure) => Set(configure, "foreach");
	public ProcessorDescriptor<TDocument> GeoGrid(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor geoGridProcessor) => Set(geoGridProcessor, "geo_grid");
	public ProcessorDescriptor<TDocument> GeoGrid(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessorDescriptor<TDocument>> configure) => Set(configure, "geo_grid");
	public ProcessorDescriptor<TDocument> Geoip(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor geoIpProcessor) => Set(geoIpProcessor, "geoip");
	public ProcessorDescriptor<TDocument> Geoip(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessorDescriptor<TDocument>> configure) => Set(configure, "geoip");
	public ProcessorDescriptor<TDocument> Grok(Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor grokProcessor) => Set(grokProcessor, "grok");
	public ProcessorDescriptor<TDocument> Grok(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessorDescriptor<TDocument>> configure) => Set(configure, "grok");
	public ProcessorDescriptor<TDocument> Gsub(Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor gsubProcessor) => Set(gsubProcessor, "gsub");
	public ProcessorDescriptor<TDocument> Gsub(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessorDescriptor<TDocument>> configure) => Set(configure, "gsub");
	public ProcessorDescriptor<TDocument> HtmlStrip(Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor htmlStripProcessor) => Set(htmlStripProcessor, "html_strip");
	public ProcessorDescriptor<TDocument> HtmlStrip(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessorDescriptor<TDocument>> configure) => Set(configure, "html_strip");
	public ProcessorDescriptor<TDocument> Inference(Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor inferenceProcessor) => Set(inferenceProcessor, "inference");
	public ProcessorDescriptor<TDocument> Inference(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessorDescriptor<TDocument>> configure) => Set(configure, "inference");
	public ProcessorDescriptor<TDocument> Join(Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor joinProcessor) => Set(joinProcessor, "join");
	public ProcessorDescriptor<TDocument> Join(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessorDescriptor<TDocument>> configure) => Set(configure, "join");
	public ProcessorDescriptor<TDocument> Json(Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor jsonProcessor) => Set(jsonProcessor, "json");
	public ProcessorDescriptor<TDocument> Json(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessorDescriptor<TDocument>> configure) => Set(configure, "json");
	public ProcessorDescriptor<TDocument> Kv(Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor keyValueProcessor) => Set(keyValueProcessor, "kv");
	public ProcessorDescriptor<TDocument> Kv(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessorDescriptor<TDocument>> configure) => Set(configure, "kv");
	public ProcessorDescriptor<TDocument> Lowercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor lowercaseProcessor) => Set(lowercaseProcessor, "lowercase");
	public ProcessorDescriptor<TDocument> Lowercase(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessorDescriptor<TDocument>> configure) => Set(configure, "lowercase");
	public ProcessorDescriptor<TDocument> NetworkDirection(Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor networkDirectionProcessor) => Set(networkDirectionProcessor, "network_direction");
	public ProcessorDescriptor<TDocument> NetworkDirection(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessorDescriptor<TDocument>> configure) => Set(configure, "network_direction");
	public ProcessorDescriptor<TDocument> Pipeline(Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor pipelineProcessor) => Set(pipelineProcessor, "pipeline");
	public ProcessorDescriptor<TDocument> Pipeline(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessorDescriptor<TDocument>> configure) => Set(configure, "pipeline");
	public ProcessorDescriptor<TDocument> Redact(Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor redactProcessor) => Set(redactProcessor, "redact");
	public ProcessorDescriptor<TDocument> Redact(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessorDescriptor<TDocument>> configure) => Set(configure, "redact");
	public ProcessorDescriptor<TDocument> RegisteredDomain(Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor registeredDomainProcessor) => Set(registeredDomainProcessor, "registered_domain");
	public ProcessorDescriptor<TDocument> RegisteredDomain(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessorDescriptor<TDocument>> configure) => Set(configure, "registered_domain");
	public ProcessorDescriptor<TDocument> Remove(Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor removeProcessor) => Set(removeProcessor, "remove");
	public ProcessorDescriptor<TDocument> Remove(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessorDescriptor<TDocument>> configure) => Set(configure, "remove");
	public ProcessorDescriptor<TDocument> Rename(Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor renameProcessor) => Set(renameProcessor, "rename");
	public ProcessorDescriptor<TDocument> Rename(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessorDescriptor<TDocument>> configure) => Set(configure, "rename");
	public ProcessorDescriptor<TDocument> Reroute(Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor rerouteProcessor) => Set(rerouteProcessor, "reroute");
	public ProcessorDescriptor<TDocument> Reroute(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessorDescriptor<TDocument>> configure) => Set(configure, "reroute");
	public ProcessorDescriptor<TDocument> Script(Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor scriptProcessor) => Set(scriptProcessor, "script");
	public ProcessorDescriptor<TDocument> Script(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessorDescriptor<TDocument>> configure) => Set(configure, "script");
	public ProcessorDescriptor<TDocument> Set(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor setProcessor) => Set(setProcessor, "set");
	public ProcessorDescriptor<TDocument> Set(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessorDescriptor<TDocument>> configure) => Set(configure, "set");
	public ProcessorDescriptor<TDocument> SetSecurityUser(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor setSecurityUserProcessor) => Set(setSecurityUserProcessor, "set_security_user");
	public ProcessorDescriptor<TDocument> SetSecurityUser(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessorDescriptor<TDocument>> configure) => Set(configure, "set_security_user");
	public ProcessorDescriptor<TDocument> Sort(Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor sortProcessor) => Set(sortProcessor, "sort");
	public ProcessorDescriptor<TDocument> Sort(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessorDescriptor<TDocument>> configure) => Set(configure, "sort");
	public ProcessorDescriptor<TDocument> Split(Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor splitProcessor) => Set(splitProcessor, "split");
	public ProcessorDescriptor<TDocument> Split(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessorDescriptor<TDocument>> configure) => Set(configure, "split");
	public ProcessorDescriptor<TDocument> Terminate(Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor terminateProcessor) => Set(terminateProcessor, "terminate");
	public ProcessorDescriptor<TDocument> Terminate(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessorDescriptor<TDocument>> configure) => Set(configure, "terminate");
	public ProcessorDescriptor<TDocument> Trim(Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor trimProcessor) => Set(trimProcessor, "trim");
	public ProcessorDescriptor<TDocument> Trim(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessorDescriptor<TDocument>> configure) => Set(configure, "trim");
	public ProcessorDescriptor<TDocument> Uppercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor uppercaseProcessor) => Set(uppercaseProcessor, "uppercase");
	public ProcessorDescriptor<TDocument> Uppercase(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessorDescriptor<TDocument>> configure) => Set(configure, "uppercase");
	public ProcessorDescriptor<TDocument> UriParts(Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor uriPartsProcessor) => Set(uriPartsProcessor, "uri_parts");
	public ProcessorDescriptor<TDocument> UriParts(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessorDescriptor<TDocument>> configure) => Set(configure, "uri_parts");
	public ProcessorDescriptor<TDocument> UrlDecode(Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor urlDecodeProcessor) => Set(urlDecodeProcessor, "urldecode");
	public ProcessorDescriptor<TDocument> UrlDecode(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessorDescriptor<TDocument>> configure) => Set(configure, "urldecode");
	public ProcessorDescriptor<TDocument> UserAgent(Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor userAgentProcessor) => Set(userAgentProcessor, "user_agent");
	public ProcessorDescriptor<TDocument> UserAgent(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessorDescriptor<TDocument>> configure) => Set(configure, "user_agent");

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(ContainedVariantName))
		{
			writer.WritePropertyName(ContainedVariantName);
			if (Variant is not null)
			{
				JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);
				writer.WriteEndObject();
				return;
			}

			JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class ProcessorDescriptor : SerializableDescriptor<ProcessorDescriptor>
{
	internal ProcessorDescriptor(Action<ProcessorDescriptor> configure) => configure.Invoke(this);

	public ProcessorDescriptor() : base()
	{
	}

	private bool ContainsVariant { get; set; }
	private string ContainedVariantName { get; set; }
	private object Variant { get; set; }
	private Descriptor Descriptor { get; set; }

	private ProcessorDescriptor Set<T>(Action<T> descriptorAction, string variantName) where T : Descriptor
	{
		ContainedVariantName = variantName;
		ContainsVariant = true;
		var descriptor = (T)Activator.CreateInstance(typeof(T), true);
		descriptorAction?.Invoke(descriptor);
		Descriptor = descriptor;
		return Self;
	}

	private ProcessorDescriptor Set(object variant, string variantName)
	{
		Variant = variant;
		ContainedVariantName = variantName;
		ContainsVariant = true;
		return Self;
	}

	public ProcessorDescriptor Append(Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor appendProcessor) => Set(appendProcessor, "append");
	public ProcessorDescriptor Append<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessorDescriptor> configure) => Set(configure, "append");
	public ProcessorDescriptor Attachment(Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor attachmentProcessor) => Set(attachmentProcessor, "attachment");
	public ProcessorDescriptor Attachment<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessorDescriptor> configure) => Set(configure, "attachment");
	public ProcessorDescriptor Bytes(Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor bytesProcessor) => Set(bytesProcessor, "bytes");
	public ProcessorDescriptor Bytes<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessorDescriptor> configure) => Set(configure, "bytes");
	public ProcessorDescriptor Circle(Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor circleProcessor) => Set(circleProcessor, "circle");
	public ProcessorDescriptor Circle<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessorDescriptor> configure) => Set(configure, "circle");
	public ProcessorDescriptor CommunityId(Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor communityIDProcessor) => Set(communityIDProcessor, "community_id");
	public ProcessorDescriptor CommunityId<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessorDescriptor> configure) => Set(configure, "community_id");
	public ProcessorDescriptor Convert(Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor convertProcessor) => Set(convertProcessor, "convert");
	public ProcessorDescriptor Convert<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessorDescriptor> configure) => Set(configure, "convert");
	public ProcessorDescriptor Csv(Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor csvProcessor) => Set(csvProcessor, "csv");
	public ProcessorDescriptor Csv<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessorDescriptor> configure) => Set(configure, "csv");
	public ProcessorDescriptor Date(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor dateProcessor) => Set(dateProcessor, "date");
	public ProcessorDescriptor Date<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessorDescriptor> configure) => Set(configure, "date");
	public ProcessorDescriptor DateIndexName(Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor dateIndexNameProcessor) => Set(dateIndexNameProcessor, "date_index_name");
	public ProcessorDescriptor DateIndexName<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessorDescriptor> configure) => Set(configure, "date_index_name");
	public ProcessorDescriptor Dissect(Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor dissectProcessor) => Set(dissectProcessor, "dissect");
	public ProcessorDescriptor Dissect<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessorDescriptor> configure) => Set(configure, "dissect");
	public ProcessorDescriptor DotExpander(Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor dotExpanderProcessor) => Set(dotExpanderProcessor, "dot_expander");
	public ProcessorDescriptor DotExpander<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessorDescriptor> configure) => Set(configure, "dot_expander");
	public ProcessorDescriptor Drop(Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor dropProcessor) => Set(dropProcessor, "drop");
	public ProcessorDescriptor Drop<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessorDescriptor> configure) => Set(configure, "drop");
	public ProcessorDescriptor Enrich(Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor enrichProcessor) => Set(enrichProcessor, "enrich");
	public ProcessorDescriptor Enrich<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessorDescriptor> configure) => Set(configure, "enrich");
	public ProcessorDescriptor Fail(Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor failProcessor) => Set(failProcessor, "fail");
	public ProcessorDescriptor Fail<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessorDescriptor> configure) => Set(configure, "fail");
	public ProcessorDescriptor Fingerprint(Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor fingerprintProcessor) => Set(fingerprintProcessor, "fingerprint");
	public ProcessorDescriptor Fingerprint<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessorDescriptor> configure) => Set(configure, "fingerprint");
	public ProcessorDescriptor Foreach(Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor foreachProcessor) => Set(foreachProcessor, "foreach");
	public ProcessorDescriptor Foreach<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessorDescriptor> configure) => Set(configure, "foreach");
	public ProcessorDescriptor GeoGrid(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor geoGridProcessor) => Set(geoGridProcessor, "geo_grid");
	public ProcessorDescriptor GeoGrid<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessorDescriptor> configure) => Set(configure, "geo_grid");
	public ProcessorDescriptor Geoip(Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor geoIpProcessor) => Set(geoIpProcessor, "geoip");
	public ProcessorDescriptor Geoip<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessorDescriptor> configure) => Set(configure, "geoip");
	public ProcessorDescriptor Grok(Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor grokProcessor) => Set(grokProcessor, "grok");
	public ProcessorDescriptor Grok<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessorDescriptor> configure) => Set(configure, "grok");
	public ProcessorDescriptor Gsub(Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor gsubProcessor) => Set(gsubProcessor, "gsub");
	public ProcessorDescriptor Gsub<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessorDescriptor> configure) => Set(configure, "gsub");
	public ProcessorDescriptor HtmlStrip(Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor htmlStripProcessor) => Set(htmlStripProcessor, "html_strip");
	public ProcessorDescriptor HtmlStrip<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessorDescriptor> configure) => Set(configure, "html_strip");
	public ProcessorDescriptor Inference(Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor inferenceProcessor) => Set(inferenceProcessor, "inference");
	public ProcessorDescriptor Inference<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessorDescriptor> configure) => Set(configure, "inference");
	public ProcessorDescriptor Join(Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor joinProcessor) => Set(joinProcessor, "join");
	public ProcessorDescriptor Join<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessorDescriptor> configure) => Set(configure, "join");
	public ProcessorDescriptor Json(Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor jsonProcessor) => Set(jsonProcessor, "json");
	public ProcessorDescriptor Json<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessorDescriptor> configure) => Set(configure, "json");
	public ProcessorDescriptor Kv(Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor keyValueProcessor) => Set(keyValueProcessor, "kv");
	public ProcessorDescriptor Kv<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessorDescriptor> configure) => Set(configure, "kv");
	public ProcessorDescriptor Lowercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor lowercaseProcessor) => Set(lowercaseProcessor, "lowercase");
	public ProcessorDescriptor Lowercase<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessorDescriptor> configure) => Set(configure, "lowercase");
	public ProcessorDescriptor NetworkDirection(Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor networkDirectionProcessor) => Set(networkDirectionProcessor, "network_direction");
	public ProcessorDescriptor NetworkDirection<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessorDescriptor> configure) => Set(configure, "network_direction");
	public ProcessorDescriptor Pipeline(Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor pipelineProcessor) => Set(pipelineProcessor, "pipeline");
	public ProcessorDescriptor Pipeline<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessorDescriptor> configure) => Set(configure, "pipeline");
	public ProcessorDescriptor Redact(Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor redactProcessor) => Set(redactProcessor, "redact");
	public ProcessorDescriptor Redact<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessorDescriptor> configure) => Set(configure, "redact");
	public ProcessorDescriptor RegisteredDomain(Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor registeredDomainProcessor) => Set(registeredDomainProcessor, "registered_domain");
	public ProcessorDescriptor RegisteredDomain<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessorDescriptor> configure) => Set(configure, "registered_domain");
	public ProcessorDescriptor Remove(Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor removeProcessor) => Set(removeProcessor, "remove");
	public ProcessorDescriptor Remove<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessorDescriptor> configure) => Set(configure, "remove");
	public ProcessorDescriptor Rename(Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor renameProcessor) => Set(renameProcessor, "rename");
	public ProcessorDescriptor Rename<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessorDescriptor> configure) => Set(configure, "rename");
	public ProcessorDescriptor Reroute(Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor rerouteProcessor) => Set(rerouteProcessor, "reroute");
	public ProcessorDescriptor Reroute<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessorDescriptor> configure) => Set(configure, "reroute");
	public ProcessorDescriptor Script(Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor scriptProcessor) => Set(scriptProcessor, "script");
	public ProcessorDescriptor Script<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessorDescriptor> configure) => Set(configure, "script");
	public ProcessorDescriptor Set(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor setProcessor) => Set(setProcessor, "set");
	public ProcessorDescriptor Set<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessorDescriptor> configure) => Set(configure, "set");
	public ProcessorDescriptor SetSecurityUser(Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor setSecurityUserProcessor) => Set(setSecurityUserProcessor, "set_security_user");
	public ProcessorDescriptor SetSecurityUser<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessorDescriptor> configure) => Set(configure, "set_security_user");
	public ProcessorDescriptor Sort(Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor sortProcessor) => Set(sortProcessor, "sort");
	public ProcessorDescriptor Sort<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessorDescriptor> configure) => Set(configure, "sort");
	public ProcessorDescriptor Split(Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor splitProcessor) => Set(splitProcessor, "split");
	public ProcessorDescriptor Split<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessorDescriptor> configure) => Set(configure, "split");
	public ProcessorDescriptor Terminate(Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor terminateProcessor) => Set(terminateProcessor, "terminate");
	public ProcessorDescriptor Terminate<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessorDescriptor> configure) => Set(configure, "terminate");
	public ProcessorDescriptor Trim(Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor trimProcessor) => Set(trimProcessor, "trim");
	public ProcessorDescriptor Trim<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessorDescriptor> configure) => Set(configure, "trim");
	public ProcessorDescriptor Uppercase(Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor uppercaseProcessor) => Set(uppercaseProcessor, "uppercase");
	public ProcessorDescriptor Uppercase<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessorDescriptor> configure) => Set(configure, "uppercase");
	public ProcessorDescriptor UriParts(Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor uriPartsProcessor) => Set(uriPartsProcessor, "uri_parts");
	public ProcessorDescriptor UriParts<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessorDescriptor> configure) => Set(configure, "uri_parts");
	public ProcessorDescriptor UrlDecode(Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor urlDecodeProcessor) => Set(urlDecodeProcessor, "urldecode");
	public ProcessorDescriptor UrlDecode<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessorDescriptor> configure) => Set(configure, "urldecode");
	public ProcessorDescriptor UserAgent(Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor userAgentProcessor) => Set(userAgentProcessor, "user_agent");
	public ProcessorDescriptor UserAgent<TDocument>(Action<Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessorDescriptor> configure) => Set(configure, "user_agent");

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(ContainedVariantName))
		{
			writer.WritePropertyName(ContainedVariantName);
			if (Variant is not null)
			{
				JsonSerializer.Serialize(writer, Variant, Variant.GetType(), options);
				writer.WriteEndObject();
				return;
			}

			JsonSerializer.Serialize(writer, Descriptor, Descriptor.GetType(), options);
		}

		writer.WriteEndObject();
	}
}